<template>
  <el-table
    ref="multipleTable"
    :data="arr"
    tooltip-effect="dark"
    style="width: 100%"
   @selection-change="handleSelectionChange"
    >
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
      <!-- <el-table-column
      label="用户ID"
      prop="id"
      type="index"
      width="70">
    </el-table-column> -->
    <el-table-column
      label="日期"
      width="150">
      <template slot-scope="scope">{{ scope.row.date }}</template>
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="120">
    </el-table-column>

     <el-table-column
      prop="address"
      label="地址"
      width="250">
    </el-table-column>
    
     <el-table-column
      label="消费金额"
      width="120">
      <template slot-scope="scope">{{ scope.row.money }}</template>
    </el-table-column>
         <el-table-column
      label="订单数量"
      width="120">
      <template slot-scope="scope">{{ scope.row.count }}</template>
    </el-table-column>
     <el-table-column
      label="会员等级"
      width="120">
      <template slot-scope="scope">{{ typeObj[scope.row.type ]}}</template>
    </el-table-column>

   <el-table-column 
  label="禁用账户"
  width="120">
  <template slot-scope="scope">
    <el-switch
     v-model="scope.row.index"
    active-color="#ff4949"
    inactive-color="#DCDFE6">
  </el-switch>
  </template>
</el-table-column>
 
 <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          type="warning"
          @click="handleEdit( scope.row)">编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="deleteone(scope.row.id)">删除</el-button>
      </template>
    </el-table-column>

  </el-table>
</template>

<script> 
import eventBus from "../../../untial/evevtBus";
  export default {
    props:['arr'],
    data() {
      return {  
        typeObj:{
   1:'普通用户',
   2:'VIP',
   3:'钻石VIP'
        } ,
        
         multipleSelection: []
      }
    },

 mounted(){
  eventBus.$on('deletemore',this.deletemore1)
 },
    methods: {

    deleteone(id){
      console.log("user",id);
   this.$emit('resetpage',id)
    },
      
//删除多个
deletemore1(){
  var ids = this.multipleSelection.map(item=>item.id)
  this.$emit('deletesome',ids)
},

   handleEdit(row){
  this.$emit('editone',row)
   },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      }
    
  }
  }
</script>

<style scoped>

</style>